import Vue from 'vue'
import App from './App.vue'
import router from './router/index'
import store from './store/store'
import axios from './config/axiosConfig'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import './assets/global.css'
import echarts from 'echarts'

Vue.use(ElementUI)

// Vue.config.debug = true
// Vue.config.productionTip = false
// Vue.config.devtools = false
Vue.prototype.$http = axios
Vue.prototype.$echarts = echarts

new Vue({
    el: '#app',
    router: router,
    store: store,
    render: h => h(App),
    created() {
        //在页面加载时读取sessionStorage里的状态信息
        if (sessionStorage.getItem('store')) {
            this.$store.replaceState(Object.assign({}, this.$store.state, JSON.parse(sessionStorage.getItem('store'))))
        }

        //在页面刷新时将vuex里的信息保存到sessionStorage里
        window.addEventListener('beforeunload', () => {
            sessionStorage.setItem('store', JSON.stringify(this.$store.state))
        })
    }
})